package zjh_20230309;

import java.util.HashMap;

public class practise02{
    public static void main(String[] args) {
        String s = "abcdefgabc";
        //key-value:字符-出现次数
        HashMap hashMap = new HashMap();
            for (int i = 0; i < s.length(); i++) {
                char c = s.charAt(i);
                if (!hashMap.containsKey(c)) {
                    hashMap.put(c, 1);
                } else {
                    Integer sum = (Integer) hashMap.get(c);
                    sum++;
                    hashMap.put(c, sum);
                }
            }
            System.out.println(hashMap);
    }
}
